package com.CST.service.impl.cb;

import com.CST.common.api.ResultObject;
import com.CST.entity.cb.CostDataInfo;
import com.CST.entity.cb.EtlDepreciation;
import com.CST.mapper.cst.cb.EtlDepreciationMapper;
import com.CST.service.cb.IEtlDepreciationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ly
 * @since 2022-01-24
 */
@Service
public class EtlDepreciationServiceImpl extends ServiceImpl<EtlDepreciationMapper, EtlDepreciation> implements IEtlDepreciationService {

    @Override
    public ResultObject getEtlDepreciationSource(EtlDepreciation entity) {
        if (entity.getIyear() == null || entity.getIyear().isEmpty()) {
            return ResultObject.errorReturn("折旧数据未能获取年份,请联系管理员");
        }
        if (entity.getMonth() == null || entity.getMonth().isEmpty()) {
            return ResultObject.errorReturn("折旧数据未能获取月份,请联系管理员");
        }
        //取查询月的字段
        entity.setFiled("dblDepr" + entity.getMonth());
        List<CostDataInfo> list = baseMapper.getEtlDepreciationSource(entity);
        return ResultObject.successReturn(list);
    }
}
